<!--
 * @Description: 
 * @Version: 1.0
 * @Author: Yuanjy
 * @Date: 2020-03-24 11:43:43
 * @LastEditors: Yuanjy
 * @LastEditTime: 2020-05-28 01:42:18
 -->
<template>
  <div class="app-container">
    <eHeader :query="query"/>
    <!--表格渲染-->
    <el-table v-loading="loading" :data="data" size="small" border style="width: 100%;">
      <el-table-column prop="id" width="80" label="ID" />
      <el-table-column prop="name" label="用户昵称" />
      <el-table-column label="用户头像">
        <template slot-scope="scope">
          <img :src="scope.row.avatar" class="el-avatar">
        </template>
      </el-table-column>
      <el-table-column label="用户性别">
        <template slot-scope="scope">
          {{ +scope.row.gender === 1 ? '男' : (+scope.row.gender === 2 ? '女' : '未知') }}
        </template>
      </el-table-column>
      <!-- <el-table-column prop="wwx_external_userid" label="企业微信ID" /> -->
      <el-table-column label="用户类型">
        <template slot-scope="scope">
          {{ +scope.row.type === 1 ? '微信用户' : ( +scope.row.type === 2 ? '企业用户' : '未知') }}
        </template>
      </el-table-column>
      <el-table-column prop="created_at" label="创建时间" />
      <el-table-column prop="updated_at" label="修改时间" />
      <el-table-column label="操作" width="320px" align="center">
        <template slot-scope="scope">
          <!-- <edit v-permission="['ADMIN']" :data="scope.row" :sup_this="sup_this" /> -->
          <!-- <import-user v-permission="['ADMIN']" :enterprise-id="scope.row.id" :sup_this="sup_this" /> -->
          <addService :data="scope.row" :sup_this="sup_this" :user-id="scope.row.id" />
        </template>
      </el-table-column>
    </el-table>
    <!--分页组件-->
    <el-pagination
      :total="total"
      style="margin-top: 8px;"
      layout="total, prev, pager, next, sizes"
      @size-change="sizeChange"
      @current-change="pageChange"/>
  </div>
</template>

<script>
import initData from '@/mixins/initData'
import eHeader from './module/header'
import edit from './module/edit'
import addService from './module/addService'

export default {
  components: { eHeader, edit, addService },
  mixins: [initData],
  data() {
    return {
      query: {
        nick_name: ''
      },
      delLoading: false,
      sup_this: this
    }
  },
  created() {
    this.$nextTick(() => {
      this.init()
    })
  },
  methods: {
    beforeInit() {
      this.url = '/admin/v1/external-user'
      const sort = 'id,desc'
      this.params = { page: this.page, limit: this.limit, sort: sort }
      if (this.query.nick_name) { 
        this.params['nick_name'] = this.query.nick_name
      }
      return true
    },
  }
}
</script>

<style scoped>

</style>
